package com.mollytask.superadmin;

import android.content.Intent;

import com.mollytask.R;
import com.mollytask.base.BaseCheckListFragment;
import com.mollytask.bean.Institution;

import java.util.List;

import cn.bmob.v3.BmobQuery;
import cn.bmob.v3.exception.BmobException;
import cn.bmob.v3.listener.FindListener;

/**
 * Created by freshxu on 2017/5/24.
 */

public class DataRecordFragment extends BaseCheckListFragment {


    public static DataRecordFragment newInstance() {
        DataRecordFragment myFragment = new DataRecordFragment();
        return myFragment;
    }


    @Override
    public int getLayout() {
        return R.layout.fragment_record;
    }

    @Override
    public boolean isCheck() {
        return false;
    }

    @Override
    public void init() {
        this.setOnCheckItemClickListener(new OnCheckItemClickListener() {
            @Override
            public void onCheckItemClick(int position) {
                Intent intent = new Intent(getActivity(), DataRecordDetailActivity.class);
                intent.putExtra("dataFillResult", mDataFills.get(position));
                BmobQuery<Institution> query = new BmobQuery<Institution>();
                query.addWhereEqualTo("mInCode", mDataFills.get(position).getmInId());
                query.findObjects(new FindListener<Institution>() {
                    @Override
                    public void done(List<Institution> list, BmobException e) {
                        if (e == null) {
                            intent.putExtra("institution", list.get(0));
                            startActivity(intent);
                        }
                    }
                });

            }
        });
    }

    @Override
    public int getRecyclerViewId() {
        return R.id.recycler_record;
    }
}